package org.boot.mq;

import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.common.message.Message;

public class MqProducer {
	
	public static void main(String[] args) throws MQClientException, InterruptedException {
		
		DefaultMQProducer producer = new DefaultMQProducer ("ProducerGroup");
		producer.setNamesrvAddr("10.0.14.16:9876");
		producer.start();
		for(int i = 0 ; i < 1000; i++){
			try{
				Message msg = new Message("TopicTest","TagTest",("hello world"+i).getBytes("utf-8"));
				SendResult sendResult = producer.send(msg);
				System.out.println(sendResult);
			}catch (Exception e) {
				e.printStackTrace();
				Thread.sleep(1000);
			}
		}
		
		
		producer.shutdown();
	}
}
